package com.ly.sy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ly.sy.entity.Syuser;
import com.ly.sy.mapper.SyuserMapper;
import com.ly.sy.service.SyuserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liangyu
 * @since 2020-11-11
 */
@Service
public class SyuserServiceImpl extends ServiceImpl<SyuserMapper, Syuser> implements SyuserService {
    @Override
    public Syuser findByuserNameAnduserPwd(String username,String userpwd) {

        QueryWrapper<Syuser> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("user_name",username);
        queryWrapper.eq("user_pwd",userpwd);
        Syuser userFormSql= getOne(queryWrapper);
        return userFormSql;
    }

    @Override
    public Syuser findByName(String username) {
        QueryWrapper<Syuser> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("user_name",username);
        Syuser userFormSql= getOne(queryWrapper);
        return userFormSql;
    }

    @Override
    public Syuser selectById(Syuser user) {
        QueryWrapper<Syuser> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("user_id",user.getUserId());
        Syuser userFormSql= getOne(queryWrapper);
        return userFormSql;
    }

    @Override
    public List<Syuser> userlikelist(String searchstr) {
        QueryWrapper<Syuser> queryWrapper=new QueryWrapper<>();
        queryWrapper.like("user_name",searchstr);
        List<Syuser> userFormSql= list(queryWrapper);
        return userFormSql;
    }

    @Override
    public Syuser findpassword(String username, String userphone) {
        QueryWrapper<Syuser> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("user_name",username);
        queryWrapper.eq("user_phone",userphone);
        Syuser userFormSql= getOne(queryWrapper);
        return userFormSql;
    }


}
